package com.lcl.jarvis.admin.modules.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.lcl.jarvis.admin.modules.business.dto.request.TbMedicalInfoPageReqDTO;
import com.lcl.jarvis.admin.modules.business.dto.request.TbMedicalInfoReqDTO;
import com.lcl.jarvis.admin.modules.business.dto.response.TbMedicalInfoRespDTO;
import com.lcl.jarvis.admin.modules.business.service.ITbMedicalInfoService;
import lombok.RequiredArgsConstructor;
import com.lcl.jarvis.common.model.R;
import com.lcl.jarvis.common.model.PageResult;

/**
 * 医疗机构信息Controller
 *
 * @author licl
 * @date 2024-06-21 11:11:22
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/medicalInfo")
public class TbMedicalInfoController {

    private final ITbMedicalInfoService tbMedicalInfoService;

    /**
     * 新增医疗机构信息
     *
     * @param body
     * @return
     */
    @PreAuthorize("hasAuthority('business:medicalInfo:add')")
    @PostMapping
    public R<Integer> add(@RequestBody TbMedicalInfoReqDTO body) {
        return R.succeed(tbMedicalInfoService.add(body));
    }

    /**
     * 删除医疗机构信息
     *
     * @param ids
     * @return
     */
    @PreAuthorize("hasAuthority('business:medicalInfo:remove')")
    @DeleteMapping("/{ids}")
    public R<Integer> remove(@PathVariable List<Long> ids) {
        return R.succeed(tbMedicalInfoService.remove(ids));
    }

    /**
     * 修改医疗机构信息
     *
     * @param body
     * @return
     */
    @PreAuthorize("hasAuthority('business:medicalInfo:edit')")
    @PutMapping
    public R<Integer> update(@RequestBody TbMedicalInfoReqDTO body) {
        return R.succeed(tbMedicalInfoService.update(body));
    }

    /**
     * 获取医疗机构信息详细信息
     *
     * @param id
     * @return
     */
    @PreAuthorize("hasAuthority('business:medicalInfo:query')")
    @GetMapping(value = "/{id}")
    public R<TbMedicalInfoRespDTO> detail(@PathVariable("id") Long id) {
        return R.succeed(tbMedicalInfoService.detail(id));
    }

    /**
     * 查询医疗机构信息列表
     *
     * @param req
     * @return
     */
    @PreAuthorize("hasAuthority('business:medicalInfo:list')")
    @GetMapping("/list")
    public R<PageResult<TbMedicalInfoRespDTO>> page(TbMedicalInfoPageReqDTO req) {
        return R.succeed(tbMedicalInfoService.page(req));
    }

}
